﻿#define _CRT_SECURE_NO_WARNINGS 1

//编程初学者入门训练第108题
//BC110 井字棋
//https://www.nowcoder.com/practice/0375c1d206ef48a3894f72aa07b2fdde?tpId=107&tqId=33391&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D3%26tpId%3D107%26type%3D107&difficulty=undefined&judgeStatus=undefined&tags=&title=

#include <stdio.h>

int main() {
    char board[3][3] = { 0 };
    char flag = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            scanf(" %c", &board[i][j]);
        }
    }
    //判断输赢
    for (int i = 0; i < 3; i++) {
        //行
        if (board[i][0] == board[i][1] && board[i][1] == board[i][2] &&
            board[i][2] != 'O') {
            flag = board[i][2];
            break;
        }
        //列
        if (board[0][i] == board[1][i] && board[1][i] == board[2][i] &&
            board[2][i] != 'O') {
            flag = board[2][i];
            break;
        }
    }
    //对角线
    if (board[0][0] == board[1][1] && board[1][1] == board[2][2] &&
        board[2][2] != 'O') {
        flag = board[2][2];
    }
    if (board[0][2] == board[1][1] && board[1][1] == board[2][0] &&
        board[2][0] != 'O') {
        flag = board[2][0];
    }

    if ('K' == flag) {
        printf("KiKi wins!\n");
    }
    else if ('B' == flag) {
        printf("BoBo wins!\n");
    }
    else {
        printf("No winner!\n");
    }

    return 0;
}